<?php

global $_W, $_GPC;
$_GPC['do'] = 'user';
$_GPC['menu'] = 'data';

$page = !empty($_GPC['page']) ? intval($_GPC['page']) : 1;

$orderBy = "fanid desc";
$keyField = "fanid";
$where = "";
// 搜索昵称
if ($nickname = $_GPC['nickname']) {
    $where = " AND nickname like '%{$nickname}%'";
}
$list = M('user')->getList($page, $where, array(), 20, $orderBy, $keyField);

$genderArr = array(
    1 => '男',
    2 => '女',
    3 => '未知'
);
foreach ($list['list'] as $key => $value) {
    if (is_base64($value['tag'])) {
        $tag = @base64_decode($value['tag']);
    }
    if (is_serialized($tag)) {
        $tag = @iunserializer($tag);
    }
//    print_r($tag);
    // 性别
    $list['list'][$key]['sex'] = $genderArr[$tag['sex']];
    // 头像
    $list['list'][$key]['avatarUrl'] = $tag['headimgurl'];
    // 地区
    $list['list'][$key]['place'] = $tag['country'].' '.$tag['province'].' '.$tag['city'];
    // 时间
    $list['list'][$key]['create_time'] = date('Y-m-d H:i:s', $value['followtime']);
}

// 统计
$total = M('user')->statistic();

include $this->template('user');